package com.dhp.bkOjquestionservice.controller;

import com.dhp.bkOjfeignclient.service.QuestionFeignClient;
import com.dhp.bkOjquestionservice.service.QuestionService;
import com.dhp.bkOjquestionservice.service.QuestionSubmitService;
import com.dhp.model.entity.Question;
import com.dhp.model.entity.QuestionSubmit;
import com.dhp.model.vo.QuestionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * feignController
 */
@RestController
@RequestMapping("/question/inner")
public class QuestionFeignController implements QuestionFeignClient{

    @Autowired
    private QuestionService questionService;

    @Autowired
    private QuestionSubmitService questionSubmitService;

    @Override
    @GetMapping("/getById")
    public Question getById(@RequestParam("questionId") Long questionId) {
        return questionService.getById(questionId);
    }

    @Override
    @GetMapping("/question_submit/getById")
    public QuestionSubmit getSubmitById(@RequestParam("submitId") Long submitId) {
        return questionSubmitService.getById(submitId);
    }

    @Override
    @PostMapping("/question_submit/updateById")
    public boolean updateById(@RequestBody QuestionSubmit questionSubmit) {
        return questionSubmitService.updateById(questionSubmit);
    }

    @Override
    @PostMapping("/question/updateById")
    public boolean updateQuestionById(@RequestBody Question question) {
        return questionService.updateById(question);
    }
}
